package session

import (
	"api-gateway-core/common"
	"api-gateway-core/datasource"
)

type GatewaySessionFactory struct {
	Configuration *common.Configuration
}

func NewGatewaySessionFactory(configuration *common.Configuration) *GatewaySessionFactory {
	return &GatewaySessionFactory{Configuration: configuration}
}

// 创建会话
func (this *GatewaySessionFactory) OpenSession(key string, InfoMap map[string]any) *GatewaySession {
	datasource := &datasource.Datasource{
		Configuration:  this.Configuration,
		DataSourceType: datasource.DUBBO,
		HttpStatement:  this.Configuration.GetStatement(key),
		InfoMap:        InfoMap,
	}
	return NewGatewaySession(this.Configuration, key, datasource)
}
